/* NSAuthor.m
 *
 * You may freely copy, distribute, and reuse the code in this example.
 * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
 * fitness for any particular use.
 *
 *  
 *
 */


#import "NSAuthor.h"

@implementation NSAuthor

- init
{
    [super init];
    return self;
}

- (void)dealloc
{
    [authorID autorelease];
    [firstname autorelease];
    [lastname autorelease];
    [address autorelease];
    [city autorelease];
    [state autorelease];
    [zip autorelease];
    [phone autorelease];
    
    [super dealloc];
}

- (NSString *)id { return [NSString stringWithFormat:@"%X", self]; }

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [super encodeWithCoder:aCoder];

    [aCoder encodeObject:authorID];
    [aCoder encodeObject:firstname];
    [aCoder encodeObject:lastname];
    [aCoder encodeObject:address];
    [aCoder encodeObject:city];
    [aCoder encodeObject:state];
    [aCoder encodeObject:zip];
    [aCoder encodeObject:phone];

    [aCoder encodeValuesOfObjCTypes:"i", &contract];
    
}

- initWithCoder:(NSCoder *)aDecoder
{
    [super initWithCoder:aDecoder];

    authorID = [[aDecoder decodeObject] retain];
    firstname = [[aDecoder decodeObject] retain];
    lastname = [[aDecoder decodeObject] retain];
    address = [[aDecoder decodeObject] retain];
    city = [[aDecoder decodeObject] retain];
    state = [[aDecoder decodeObject] retain];
    zip = [[aDecoder decodeObject] retain];
    phone = [[aDecoder decodeObject] retain];
    
    [aDecoder decodeValuesOfObjCTypes:"i", &contract];
    

    return self;
}

- (NSString *)description
{
    NSMutableString *string;
    
    string = [NSMutableString stringWithFormat:@"{\n"];
    [string appendFormat:@"\tauthorID = %@\n", authorID];
    [string appendFormat:@"\tfirstname = %@\n", firstname];
    [string appendFormat:@"\tlastname = %@\n", lastname];
    [string appendFormat:@"\taddress = %@\n", address];
    [string appendFormat:@"\tcity = %@\n", city];
    [string appendFormat:@"\tstate = %@\n", state];
    [string appendFormat:@"\tzip = %@\n", zip];
    [string appendFormat:@"\tphone = %@\n", phone];
    [string appendFormat:@"\tcontract = %d\n", contract];
    [string appendFormat:@"}\n", address];

    
    return string;
}
@end